package com.cn.wanxi.servlet;

import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.model.NavModel;
import com.cn.wanxi.model.NewsModel;
import com.cn.wanxi.service.CompanyService;
import com.cn.wanxi.service.NavService;
import com.cn.wanxi.service.NewsService;

import javax.servlet.http.HttpServletRequest;

class CommonServlet {
    static void setCompanyAndNavData(HttpServletRequest req) {
        /**
         * 取公司信息
         */
        CompanyService companyService = new CompanyService();
        CompanyModel companyModel = companyService.getCompanyModel();
        req.setAttribute("companyModel", companyModel);

        /**
         * 取菜单信息
         */
        NavService navService = new NavService();
        NavModel[] navModels = navService.getNavModels();
        req.setAttribute("navModels", navModels);

        /**
         * 取foot栏新闻信息
         */
        NewsService newsService = new NewsService();
        NewsModel[] footNewsModels = newsService.getNewsModelsForMain();
        req.setAttribute("footNewsModels", footNewsModels);

    }

}
